/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package ebookmgr;

import javax.swing.ImageIcon;
import javax.swing.UIManager;

/**
 *
 * @author mazhao
 */
public class EBookMgr {

    public static void main(String[] args) {


        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {

                // 1. set ui look and feel

                try {

                    //UIManager.setLookAndFeel("org.fife.plaf.Office2003.Office2003LookAndFeel");
                    //UIManager.setLookAndFeel("org.fife.plaf.OfficeXP.OfficeXPLookAndFeel");
                    //UIManager.setLookAndFeel("org.fife.plaf.VisualStudio2005.VisualStudio2005LookAndFeel");
                    String systemLaF = UIManager.getSystemLookAndFeelClassName();
                    UIManager.setLookAndFeel(systemLaF);
                    //UIManager.put("Tree.expandedIcon", new ImageIcon(getClass().getResource("images/folder-open.gif")));
                    //UIManager.put("Tree.collapsedIcon", new ImageIcon(getClass().getResource("images/folder.gif")));
                    UIManager.put("Tree.leafIcon", new ImageIcon(getClass().getResource("images/leaf.gif")));
                    UIManager.put("Tree.openIcon", new ImageIcon(getClass().getResource("images/folder-open.gif")));
                    UIManager.put("Tree.closedIcon", new ImageIcon(getClass().getResource("images/folder.gif")));

                } catch (Exception e) {
                    System.err.println("Oops!  Something went wrong!");
                    e.printStackTrace();
                }

                // 2. init database
                DatabaseUtil.initDatabase();

                // 3. show main frame
                MainFrame frame = new MainFrame();
                EBookMgrUtil.setJFrameCenter(frame);

                frame.setVisible(true);
            }
        });


    }

    // for test dynamic load jar
    public void start() {
        try {
            //UIManager.setLookAndFeel("org.fife.plaf.Office2003.Office2003LookAndFeel");
            //UIManager.setLookAndFeel("org.fife.plaf.OfficeXP.OfficeXPLookAndFeel");
            UIManager.setLookAndFeel("org.fife.plaf.VisualStudio2005.VisualStudio2005LookAndFeel");
        } catch (Exception e) {
            System.err.println("Oops!  Something went wrong!");
            e.printStackTrace();
        }
        MainFrame frame = new MainFrame();

        frame.setVisible(true);
    }
}
